﻿<%@ Page Language="C#" MasterPageFile="~/SubForm.Master" AutoEventWireup="true" CodeBehind="AllPre-Contracts.aspx.cs"
    EnableEventValidation="false" Inherits="PreContractWeb.Task.AllPre_Contracts" %>

<%@ Register Src="../UserControl/Pager.ascx" TagName="Pager" TagPrefix="uc1" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script language="javascript" type="text/javascript">

        function OnDelete() {
            var chkList = document.documentElement.getElementsByTagName("INPUT");
            var chk;
            var n = 0;


            for (var i = 0; i < chkList.length; i++) {
                chk = chkList[i];

                if (chk.type == "checkbox" && chk.id.indexOf("_chkSelect") > 0) {
                    //alert(chk.id);
                    if (chk.checked)
                        n++;
                }

            }
            if (n == 0)
                alert("请选择至少一项!\n Please select at least one item!");
            else {
                if (confirm("确认删除所选项吗？\nAre you sure to delete selected item(s)?")) {
                    var btn = document.getElementById("ctl00_ContentPlaceHolder1_btnDelete");
                    btn.removeAttribute("autopostback");
                }
            }


            //&& chk.id!=="chkAll"
        }
        function ShowPage(id) {
            var arg = null;

            var top = (screen.height - 600) / 2;
            var left = (screen.width - 800) / 2;
            arg = window.open('EditPreContractInfo.aspx?id=' + id, '', 'menubar=0,resizable=1,scrollbars=yes');

            if (arg != null) {

                document.getElementById('<%=returnvalue.ClientID%>').value = arg[0];
            }
        }


        function SendMail() {
            //var lblErr=document.getElementById("ctl00_ContentPlaceHolder1_divError");
            //lblErr.innerHTML="正在发送邮件，请等待。Sending email, please wait.....";
            //lblErr.style.visibility="visible";
            document.getElementById("AJAXProgress").style.visibility = "visible";

            window.setTimeout(ShowEmailPage, 20);


        }



        function ShowEmailPage() {
            var arg = null;

            var id = "";
            var no = "";

            //     var lblErr=document.getElementById("ctl00_ContentPlaceHolder1_divError");
            //      //lblErr.innerHTML="正在发送邮件，请等待。Sending email, please wait.....";
            //      lblErr.style.visibility="visible";



            //Joan modified 2008-10-24
            //for perfomance

            var chkList = document.documentElement.getElementsByTagName("INPUT");
            var chk;
            var n = 0;
            var strid;

            for (var i = 0; i < chkList.length; i++) {
                chk = chkList[i];
                if (chk.type == "checkbox" && chk.id.indexOf("_chkSelect") > 0) {
                    if (chk.checked) {
                        strid = chk.id;
                        id = id + document.getElementById(strid.substring(0, strid.indexOf("_chkSelect")) + "_PreContractId").innerHTML + ",";
                        no = no + document.getElementById(strid.substring(0, strid.indexOf("_chkSelect")) + "_PreContractNo").innerHTML + ",";

                    }
                }
            }

            //end	

            if (id == "")    //not selected
            {
                //lblErr.innerHTML=""; 
                //lblErr.style.visibility="hidden";
                document.getElementById("AJAXProgress").style.visibility = "hidden";

                alert("请先选择至少一个预合同!\n\nPlease select at least one contract!");
                return;
            }


            var top = (screen.height - 350) / 2;
            var left = (screen.width - 800) / 2;
            var selIDs = id + '|' + no;
            //alert(selIDs.length);
            //?id='+selIDs


            arg = window.showModalDialog('SendEmail.aspx', new String(selIDs + ' '), 'dialogHeight:380px;dialogWidth:850px;dialogTop:' + top + ';dialogLeft:' + left + ';center:Yes;scroll:yes;resizable:yes;status:no;');
            //lblErr.innerHTML=""; 
            //lblErr.style.visibility="hidden";
            document.getElementById("AJAXProgress").style.visibility = "hidden";
            if (arg != null) {

                document.getElementById('<%=returnvalue.ClientID%>').value = arg[0];
            }

        }
  
    </script>
    <div id="divError" style="visibility: hidden;">
        正在发送邮件，请等待。Sending email, please wait.....</div>
    <div style="text-align: center;" id="divContent">
        <input id="returnvalue" type="hidden" name="returnvalue" runat="server" />
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td width="100%" height="100%" valign="middle" align="center">
                    <table width="100%" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td class="panel_header">
                                预合同列表 (Pre-Contract List)
                            </td>
                        </tr>
                        <tr>
                            <td class="panel_body">
                                <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td>
                                            <br />
                                            <table width="30%" border="0" cellpadding="0" cellspacing="0">
                                                <tr>
                                                    <td id="tdStatusText" runat="server" align="left" valign="middle">
                                                        预合同状态:<br />
                                                        Pre-Contract Status:
                                                    </td>
                                                    <td id="tdStatus" runat="server" align="left" valign="middle">
                                                        <asp:DropDownList ID="ddlContractStatus" runat="server" AutoPostBack="True" Width="120px"
                                                            OnSelectedIndexChanged="ddlContractStatus_SelectedIndexChanged">
                                                        </asp:DropDownList>
                                                    </td>
                                                    <td align="left" valign="middle">
                                                        <asp:Button ID="btnAddNew" OnClientClick="javascript:ShowPage('0'); return false;"
                                                            CssClass="bgButton" autopostback="false" runat="server" Text="新增预合同(New Pre-Contract)"
                                                            Width="200px" />
                                                        <asp:Button ID="btnDelete" OnClick="btnDelete_Click" autopostback="false" CssClass="bgButton"
                                                            runat="server" Text="删除预合同(Delete Pre-Contract)" OnClientClick="OnDelete();"
                                                            Width="200px" />
                                                        <asp:Button ID="btnSendEmail" CssClass="bgButton" runat="server" Text="发送 Email (Send Email)"
                                                            OnClientClick="javascript:SendMail(); return false;" autopostback="false" Width="150px" />
                                                        <asp:Button ID="btnExport" CssClass="bgButton" runat="server" Text="导出(Export)" Width="100px"
                                                            OnClick="btnExport_Click" />
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="right" height="1" valign="middle" style="border-top: 1px; border-top-color: #BBBBBB;
                                            border-top-style: dashed; font-size: xx-small;">
                                            &nbsp;
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="left" valign="middle">
                                            <b>&nbsp;总数(Total):<span id="totalSpan" runat="server"></span></b>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <asp:Panel ID="Panel1" runat="server" HorizontalAlign="Center" Width="100%" Height="100%">
                                                <%--   <div style="overflow: auto;" id="ctl00_ContentPlaceHolder1_divReport">--%>
                                                <asp:GridView ID="gvMain" runat="server" AutoGenerateColumns="False" Width="5200px"
                                                    AllowPaging="True" PageSize="10" DataKeyNames="PreContractID" AllowSorting="True"
                                                    OnRowDataBound="gvMain_RowDataBound" OnSorting="gvMain_Sorting">
                                                    <PagerSettings Visible="False"></PagerSettings>
                                                    <RowStyle Height="20px" CssClass="table_row_1"></RowStyle>
                                                    <SelectedRowStyle CssClass="SelectedRow"></SelectedRowStyle>
                                                    <HeaderStyle CssClass="table_header"></HeaderStyle>
                                                    <AlternatingRowStyle CssClass="table_row_2"></AlternatingRowStyle>
                                                    <EmptyDataTemplate>
                                                        <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                                            <tr>
                                                                <td>
                                                                    没有数据(No Data).
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </EmptyDataTemplate>
                                                    <Columns>
                                                        <asp:BoundField DataField="PreContractID" HeaderText="PreContractID" InsertVisible="False"
                                                            ReadOnly="True">
                                                            <ItemStyle CssClass="hidden"></ItemStyle>
                                                            <HeaderStyle CssClass="hidden" Wrap="False"></HeaderStyle>
                                                            <FooterStyle CssClass="hidden"></FooterStyle>
                                                        </asp:BoundField>
                                                        <asp:BoundField DataField="PreContractNo" HeaderText="PreContractNo">
                                                            <ItemStyle CssClass="hidden"></ItemStyle>
                                                            <HeaderStyle CssClass="hidden" Wrap="False"></HeaderStyle>
                                                            <FooterStyle CssClass="hidden"></FooterStyle>
                                                        </asp:BoundField>
                                                        <asp:TemplateField ItemStyle-Width="30px">
                                                            <HeaderTemplate>
                                                                <input type="checkbox" id="chkAll" name="chkAll" onclick="javascript: return CheckAll(this.checked, this.id);" />
                                                            </HeaderTemplate>
                                                            <ItemTemplate>
                                                                <asp:CheckBox ID="chkSelect" runat="server" />
                                                            </ItemTemplate>
                                                            <ItemStyle HorizontalAlign="Center"></ItemStyle>
                                                        </asp:TemplateField>
                                                        <asp:BoundField DataField="PreContractNo" HeaderText="预合同号<br>Pre-Contract#" SortExpression="PreContractNo"
                                                            HtmlEncode="False">
                                                            <ItemStyle HorizontalAlign="Center" Width="120px" />
                                                        </asp:BoundField>
                                                    </Columns>
                                                </asp:GridView>
                                                <uc1:Pager ID="pgMain" runat="server" />
                                                <%--   </div>--%>
                                            </asp:Panel>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td style="display: none">
                    <asp:Label ID="lblSpecialApprove" runat="server" />
                    <asp:Label ID="lblDeliveredIndex" runat="server" />
                </td>
            </tr>
        </table>
    </div>
    <script language="javascript" type="text/javascript">
        var name = document.getElementById("divContent");
        ResizeDivForScroll(name)
        window.attachEvent("onresize", resizeFuncAllPreContract);
        resizeFuncAllPreContract();
        document.getElementById("AJAXProgress").style.visibility = 'hidden';
    </script>
</asp:Content>
